import java.util.Stack;

/**
 * @ClassName:
 * @author:
 * @Description:
 * @Date
 **/
//栈实现队列
public class MyQueue {
    Stack<Integer> stack;

    public MyQueue() {
        stack = new Stack<>();
    }

    public boolean empty() {
        return stack.isEmpty();
    }

    public int pop() {
        return stack.pop();
    }

    public int peek() {
        return stack.peek();
    }

    //队尾添加元素
    public void push(int e) {
        Stack<Integer> stack2 = new Stack<>();
        while (!stack.isEmpty()) {
            //相当于把stack的元素倒过来放到stack2中
            stack2.push(stack.pop());
        }
        stack.push(e);
        while (!stack2.isEmpty()) {
            //把stack2中的元素放入stack中
            stack.push(stack2.pop());
        }
    }
}
